package com.github.boluo1230.wechat.dao.impl;

import com.github.boluo1230.wechat.dao.QrAutoReplyInfoDao;
import com.github.boluo1230.wechat.entity.QrAutoReplyInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Repository;

/**
 * @author Code Farmer
 * @date 2019/10/16 11:28
 */
@Repository
public class QrAutoReplyInfoDaoImpl implements QrAutoReplyInfoDao {

    @Autowired
    private MongoTemplate mongoTemplate;

    public QrAutoReplyInfo getQrByAppIdAndEventKey(String appId, String eventKey) {
        Query query = new Query();
        query.addCriteria(Criteria.where("appId").is(appId).and("eventKey").is(eventKey));
        return mongoTemplate.findOne(query, QrAutoReplyInfo.class);
    }

}
